package com.service.impl;

import com.mapper.UserMapper;
import com.pojo.PageResult;
import com.pojo.User;
import com.pojo.UserExtends;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(String username, String password) {
    return userMapper.login(username,password);
  }

    @Override
    public int register(User user) {
        return userMapper.inserUser(user);
    }

    @Override
    public List<User> getList(String name){
        return  userMapper.selectUser(name);
    }

    @Override
    public User selectUserById(Integer id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int deleteUserById(Integer id) {
        return userMapper.deleteUserById(id);
    }

    public PageResult selectUserList(Integer pageNum,Integer pageSize){
        pageHelper.starPage(pageNum,pageSize);
        page<UserExtend> page=(Page<UserExtend>)userMapper.selectUserList();
        PageResult pageResult=new PageResult(page.getTotal(),page.getResult(),page.getPages());
        return null;
    }
}

